#!/usr/bin/env python
# coding: utf-8
import web
from config import settings
from datetime import datetime

db = settings.db
tb = 'tags'

#获取标签列表
def get_tags(pageindex,pagesize):
	begin = (pageindex - 1) * pagesize
	return db.select(tb,
			order = 'id ASC',	
			limit =  '$begin ,$pagesize',
			vars = locals()
			)

#更新标签列表
def update_tag(id,tagname,color,visible):
	db.update(tb,
			where = 'id = $id',
			vars = locals(),
			tagname = tagname,
			color = color,
			visible = visible)

#删除标签
def del_tag(id):
	db.delete(tb,
			where = 'id = $id',
			vars = locals())

#添加标签
def new_tag(tagname,color,visible):
	db.insert(tb,
			tagname = tagname,
			color = color,
			visible = visible)


